package com.ruixun.shopmanagement.util;

import java.lang.reflect.Field;

public class CheckEntity {
	/****
	 * @param object 对象
	 * @return 如果对象不为空，且没有空值。返回false，对象为空或者有空值，返回true
	 * */
	   public static boolean checkObjFieldIsNull(Object object) {
	      boolean flag = false;
	      if(null!=object){
	         for(Field field : object.getClass().getDeclaredFields()){
	            field.setAccessible(true);//在用反射时访问私有变量（private修饰变量）
	            try {
					if(field.get(object) == null || field.get(object).equals("")){
					   flag = true;
					   return flag;
					}
				} catch (IllegalArgumentException | IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	            try {
					if(field.get(object) != null&&field.get(object).toString().trim().equals("")){
					   flag = true;
					   return flag;
					}
				} catch (IllegalArgumentException | IllegalAccessException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
	         }
	      }else{
	         flag=true;
	      }
	      return flag;
	   }

}
